package client.gwt;

import client.ConfigHelper;
import com.google.gwt.user.client.ui.impl.RichTextAreaImplOpera;
import com.google.gwt.user.client.DOM;

/**
 * Created by IntelliJ IDEA.
 * User: Wouter Wendelen
 * Date: 17-okt-2007
 * Time: 16:23:10
 */
public class MyRichTextAreaImplOpera extends RichTextAreaImplOpera {

    public void initElement() {
        initElement(ConfigHelper.getCssUrl(DOM.getElementAttribute(getElement(), "title")));
    }

    public native void initElement(String cssUrl)  /*-{
    // Most browsers don't like setting designMode until slightly _after_
    // the iframe becomes attached to the DOM. Any non-zero timeout will do
    // just fine.
    var _this = this;
    setTimeout(function() {
      // add css
      var styles = "@import url('" + cssUrl + "');";
      var newSS=document.createElement('link');
      newSS.rel='stylesheet';
      newSS.href='data:text/css,'+escape(styles);
      _this.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem.contentWindow.document.getElementsByTagName("head")[0].appendChild(newSS);


      // Turn on design mode.
      _this.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On';

      // Send notification that the iframe has reached design mode.
      _this.@com.google.gwt.user.client.ui.impl.RichTextAreaImplStandard::onElementInitialized()();
       _this.@com.google.gwt.user.client.ui.impl.RichTextAreaImpl::elem.contentWindow.document.oncontextmenu=function() {  return false};  
    }, 1);
  }-*/;
}
